//
//  CLheadCell.m
//  I-want-go
//
//  Created by dllo on 15/10/23.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "CLheadCell.h"
#import "BaseModel.h"
#import "CLphoneCollectionViewCell.h"
#import "CLtool.h"
#import "CLhottopic.h"
#import "CLeverydayController.h"
#import "CLscreen.h"
@interface CLheadCell ()<UICollectionViewDataSource, UICollectionViewDelegate >
@property(nonatomic, retain)NSMutableArray *arr;
@property(nonatomic, retain)UILabel *collectionLabel;

@end
@implementation CLheadCell
- (void)dealloc {
    [_contentLabel release];
    [_collectionLabel release];
    [_arr release];
    [_phoneCollectionView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
     }
    return self;
}
- (void)createView {
    
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.backgroundColor = [UIColor whiteColor];
    self.contentLabel.frame = CGRectMake(20 * SWIDTH, 10 * SHEIGHT, 340* SWIDTH, 200 * SHEIGHT);
    self.contentLabel.font = [UIFont systemFontOfSize:18];
    self.contentLabel.numberOfLines = 0;
    [self.contentView addSubview:self.contentLabel];
    [_contentLabel release];
    
    
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(50 * SWIDTH, 50 * SHEIGHT);
    self.phoneCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 240 * SHEIGHT, 375 * SWIDTH, 60 * SHEIGHT) collectionViewLayout:flowLayout];
    self.phoneCollectionView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.phoneCollectionView];
    [_phoneCollectionView release];
    [self.phoneCollectionView registerClass:[CLphoneCollectionViewCell class] forCellWithReuseIdentifier:@"raue"];
    flowLayout.sectionInset = UIEdgeInsetsMake(2 * SWIDTH, 10 * SHEIGHT, 2 * SWIDTH, 2 * SHEIGHT);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    
    self.collectionLabel = [[UILabel alloc] initWithFrame:CGRectMake(10 * SWIDTH, 220 * SHEIGHT, 100 * SWIDTH, 30 * SHEIGHT)];
    self.collectionLabel.text = @"人  气  榜";
    self.collectionLabel.textColor = [UIColor redColor];
    [self.contentView addSubview:self.collectionLabel];
    [_collectionLabel release];
    
    self.phoneCollectionView.dataSource = self;
    self.phoneCollectionView.delegate = self;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 6;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    CLphoneCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"raue" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    
    CLhottopic *tol = [[CLhottopic alloc] init];
    tol = self.hottpArr[indexPath.row];
    
    if (indexPath.row == 5) {
        cell.popImage.image = [UIImage imageNamed:@"right.png"];
    } else {
       [cell.popImage sd_setImageWithURL:[NSURL URLWithString:tol.avatar]];
    }
    
    
       return cell;
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    [self.Delegateaa takeValue];
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
